@import "@automattic/typography/styles/variables";

$theme-card-info-height: 48px;
$theme-card-info-margin-top: 16px;

.card.theme-card {
	background: none;
	border-radius: 2px;
	box-shadow: none;
	cursor: default;
	padding: 0;
	margin: 0 16px 48px;
	transition: all 100ms ease-in-out;

	&--is-active {
		.theme-card__image-container {
			box-shadow: 0 0 0 2px var(--color-primary);
			border-radius: 4px;
			z-index: 10;
		}
	}

	&--is-actionable {
		.theme-card__image {
			cursor: pointer;
		}
	}

	.theme-card__info-badge-container {
		align-items: center;
		display: flex;
		font-size: 0;
		gap: 4px;
		height: 24px;
	}

	.theme-card__info-badge-active {
		display: flex;
		background-color: var(--color-primary);
		color: var(--studio-white);
		font-weight: 400;

		svg {
			margin-right: 3px;
			margin-top: 1px;
		}
	}
}

.theme-card__content {
	overflow: visible;
	padding: 0;
	position: relative;
}

.theme-card__image-container {
	box-shadow: 0 12px 20px rgba(0, 0, 0, 0.04);
	border: 1px solid rgba(220,220,222,0.4);
	overflow: hidden;
	padding-top: 74%;
	position: relative;
	border-radius: 4px;
	transition: transform 100ms ease-out;
}

.theme-card--is-actionable {
	.theme-card__image {
		transition: transform 300ms ease-in-out;

		&:hover,
		&:focus {
			transform: scale(1.03);

			.theme-card__image-label {
				animation: theme-card__image-label 150ms ease-in-out;
			}
		}

		.accessible-focus &:focus &-label {
			box-shadow: 0 0 0 2px var(--color-primary-light);
		}
	}

	&:hover,
	&:focus-within {
		.theme-card__image-container {
			border-color: var(--studio-blue-50);
		}
	}
}

.theme-card__image {
	cursor: default;
	height: 100%;
	left: 0;
	opacity: 1;
	position: absolute;
	top: 0;
	transition: all 200ms ease-in-out;
	width: 100%;

	&-label {
		background: var(--color-surface);
		border: 1px solid var(--color-neutral-0);
		border-radius: 2px;
		color: var(--color-neutral-70);
		font-size: $font-body-extra-small;
		font-weight: 600;
		left: 50%;
		margin-bottom: -54px;
		opacity: 0;
		padding: 6px 9px;
		pointer-events: none;
		position: absolute;
		text-transform: uppercase;
		top: 45%;
		transform: translate(-50%, 0);
		z-index: 1;
	}

	img {
		box-sizing: border-box;
		display: block;
		height: auto;
		left: 0;
		min-height: 100%;
		padding: 0;
		position: absolute;
		right: 0;
		top: 0;
		width: 100%;
	}
}

@keyframes theme-card__image-label {
	0% {
		transform: translate3d(-50%, 10px, 0);
	}
}

.theme-card__loading {
	bottom: $theme-card-info-height + $theme-card-info-margin-top;
	background: color-mix(in srgb, var(--color-neutral-dark) 50%, transparent);
	left: 0;
	position: absolute;
	top: 0;
	width: 100%;
	z-index: 1;

	&-dot {
		animation: dot-pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
		animation-play-state: running;
		background: var(--color-neutral-0);
		border: none;
		border-radius: 100%;
		box-shadow: 0 0 0 0 rgba(168, 190, 206, 0.7);
		display: block;
		height: 6px;
		left: 50%;
		position: absolute;
		top: 50%;
		transform: translate3d(0, 0, 0);
		width: 6px;
	}
}

@keyframes dot-pulse {
	to {
		box-shadow: 0 0 0 15px rgba(90, 153, 220, 0);
	}
}

.theme-card__tooltip {
	@mixin popover__arrow( $side ) {
		&.is-#{$side},
		&.is-#{$side}-left,
		&.is-#{$side}-right {
			.popover__arrow {
				// Reset the original style.
				border-color: transparent;
				&::before {
					// Change the color according to ThemeCard's needs.
					border-#{$side}-color: var(--color-neutral-60);
				}
			}
		}
	}
	@include popover__arrow( top );
	@include popover__arrow( bottom );

	ul {
		list-style: none;
		margin: 0;
		padding: 0;

		li {
			font-size: $font-body-extra-small;
			font-weight: 400;
			border: 0;
			padding: 2px 0;
		}
	}

	.popover__arrow {
		border-width: 6px;
	}

	.popover__inner {
		border: 0;
		box-shadow: none;
		border-radius: 2px;
		color: var(--color-text-inverted);
		background: var(--color-neutral-60);
		font-size: $font-body-extra-small;
		max-width: 300px;
		padding: 6px 10px;
		text-align: left;
	}
}

.theme-card__info {
	align-items: flex-start;
	background: transparent;
	bottom: 0;
	box-sizing: initial;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 4px;
	height: $theme-card-info-height;
	left: 0;
	margin-top: $theme-card-info-margin-top;
	position: relative;
	right: 0;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;

	&-badge {
		border-radius: 20px;  /* stylelint-disable-line scales/radii */
		flex: 0 0 auto;
		text-transform: none;
		font-size: $font-body-extra-small;
		font-weight: 600;
		line-height: 20px;
		padding: 0 10px;

		&-active {
			background-color: var(--color-primary-0);
			color: var(--color-neutral-100);
		}
	}
}

.theme-card__info-soft-launched {
	position: absolute;
	top: 7px;
	left: 7px;

	&-banner {
		background-color: var(--color-warning-20);
		color: var(--color-warning-80);
		font-size: 0.725rem; /* stylelint-disable-line scales/font-sizes */
		font-weight: bold;
		line-height: 1.2;
		text-transform: uppercase;
		padding: 3px 6px;
		border-radius: 2px;
	}
}

.theme-card__info-title {
	color: var(--color-neutral-80);
	flex: 1 1 auto;
	font-family: inherit;
	font-size: $font-body;
	font-weight: 500;
	line-height: 24px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	position: relative;
	white-space: nowrap;
	width: 0;
	text-overflow: ellipsis;
}

.theme-card__info-style-variations {
	align-items: center;
	display: flex;
	font-size: 0;
	gap: 4px;
	height: 24px;

	.style-variation__badge-wrapper,
	.style-variation__badge-more-wrapper {
		&:focus-visible span {
			box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--color-primary-light);
		}
	}
}

.theme-card__info-options,
.theme-card__info-options .theme__more-button {
	border: 0;
	display: flex;
	flex: 0 0 auto;
	transition: all 0.1s ease-in-out;
	align-self: center;

	&:hover {
		background-color: initial;
	}

	button {
		cursor: pointer;
		font-size: 0;
		padding: 0;
		margin-bottom: 27px;
	}
}
